import { defAxios as request } from '@/utils/http';
import { RSAUtils } from '@/utils/';

/**
 * 登录api接口集合
 *
 * @method signIn 用户登录
 * @method signOut 用户退出登录
 */
export function useLoginApi() {
	return {
		login: (params) => {
			return request({
				url: '/login',
				data: params,
				method: 'post',
				headers: { isToken: false },
			});
		},
		/**
		 * 穿透式调用登录
		 * @param {Object} params 参数
		 * @returns request
		 */
		externalCallLogin({ sid }) {
			let headers = { sid };
			const reqData = {
				code: sid,
				uuid: sid,
				userCode: sid,
				password: sid,
			};
			return request({
				url: '/login',
				data: reqData,
				method: 'post',
				headers: headers,
			});
		},
		logout: () => {
			return request({
				url: '/logout',
				method: 'post',
			});
		},
		getCaptcha: (uuid) => {
			return request({
				url: `/sysParam/captcha?uuid=${uuid}&idt=${Date.now()}`,
				method: 'get',
			});
		},
	};
}
